-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] The date-processor doesn't parse times in AM/PM format #4564
Conversation
Signed-off-by: Federico Brignola <160846842+federicobrignola@users.noreply.github.com>
I am crossing the same bug. Why did you remove completly the parseDefaulting(ChronoField.HOUR_OF_DAY, 0) ? Something like that might be less problematic ?
|
I didn't completely remove the line Looking at your code:
Removing the unnecessary line we obtain the same code as mine. |
@FedericoBrignola Thanks for your clarification. This is now clear for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for providing this fix. Would you mind adding a test case, that forces this change?
I took a look at the tests and they are not so straightforward. I don't have time right now to study how they implemented those test cases and write a new compliant one. |
@FedericoBrignola , I do think that this makes sense overall. Can you add a couple unit test cases? One would be to parse without the |
Signed-off-by: Federico Brignola <160846842+FedericoBrignola@users.noreply.github.com>
I added 4 test cases:
While developing those test cases I found another problem in the default setting of
|
@dlvenable, can you review the pull request? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you @FedericoBrignola !
Description
The date-processor doesn't parse times in AM/PM format. For example the following timestamp format should be successfully parsed by the pattern below, but instead it gets ignored.
Example timestamp in AM/PM format:
05/20/2024 01:11:06:264 PM UTC
That timestamp should be parsed by this pattern:
MM/dd/yyyy KK:mm:ss:SSS a z
So to parse times in AM/PM format you need to use "h" [ clock-hour-of-am-pm (1-12) ] or "K" [ hour-of-am-pm (0-11) ] pattern letters. However, using these pattern letters conflicts with the default configuration (HOUR_OF_DAY = 0) of the
DateTimeFormatterBuilder, throwing the following exception:
Note: The exceptions thrown by formatters are ignored by the date-processor.
This file main.java.tar.gz is a Java class, which I used to study and patch that bug, with the "copy-pasted" method used by date-processor to build the formatters. There is also a patched version of that method
getSourceFormatter_patched
.Steps to reporduce
Try to parse the following Json lines:
with this pipeline:
The output should contain the
@timestamp
field, but it doesn't.Issues Resolved
No open issue
Check List
New functionality includes testing.New functionality has a documentation issue. Please link to it in this PR.New functionality has javadoc addedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.